<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<h1>ajax入门案例</h1>
		<script src="../js/axios.js"></script>
		<!-- AJax  局部刷新，异步访问 -->
		<script>
			//3.Axios优化   公共路径部分
			axios.defaults.baseURL="http://localhost:8080";		
			//1.promise是Axios封装
			let url1="/axios/findStr";
			axios.get("/axios/findStr")
				.then(function(promise){
					//console.log(promise)//Object
					console.log(promise.data)
				})
				
				//2.带有参数的调用
				let url2="http://localhost:8080/axios/getByid?id=102";
				axios.get(url2)
						.then(function(promise){
							console.log(promise.data)
						})	
				//3.对象参数传递  http://localhost:8080/axios/getByid?id=102&name=tomcat
							let user = {id:100,name:"tomcat"}
										axios.get("/axios/findUser",{params:user})
											 .then(function(promise){
												 console.log(promise.data)
											 })							
				//4.RestFul结构实现数据传递  第一种:简单操作
							let rest1 = {id: 12,name: "tomcat",age: 19}
							axios.get("/axios/result/"+rest1.id+"/"+rest1.name+"/"+rest1.age)
								 .then(function(promise){
									 console.log(promise.data)
								 })
				//5.RestFul  http://localhost:8080/axios/getByid?id=102&name=tomcat
				let rest2 = {id: 1001,name: "tomcat",age: 19}
							axios.get(`/axios/result/${rest2.id}/${rest2.name}/${rest2.age}`)
							.then(function(promise){
							  console.log(promise.data)
							})
							
							
							
			//6.post
					
					
					
					//模板字符串 保证代码格式
								let div = `<div>
												<p>天青色等烟雨</p>
												<p>而我在等你</p>
												<p>炊烟袅袅升起</p>
												<p>隔江千万里</p>
										   </div>`	
		</script>
	</body>
</html>
